//
//  UIView+HJ.m
//  XCYD
//
//  Created by 黄杰 on 15/6/30.
//  Copyright (c) 2015年 &#40644;&#26480;. All rights reserved.
//

#import "UIView+HJ.h"

@implementation UIView (HJ)

- (void)rotate360WithDuration:(CGFloat)duration repeatCount:(float)repeatCount
{
    
    CABasicAnimation *fullRotation;
    fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    fullRotation.fromValue = [NSNumber numberWithFloat:0];
    //fullRotation.toValue = [NSNumber numberWithFloat:(2*M_PI)];
    fullRotation.toValue = [NSNumber numberWithFloat:-(2*M_PI)]; // added this minus sign as i want to rotate it to anticlockwise
    fullRotation.duration = duration;
    fullRotation.speed = 2.0f;              // Changed rotation speed
    if (repeatCount == 0)
        fullRotation.repeatCount = MAXFLOAT;
    else
        fullRotation.repeatCount = repeatCount;
    
    [self.layer addAnimation:fullRotation forKey:@"360"];
}

@end
